package cn.quang.search.toolkit.enums;

import java.util.HashMap;
import java.util.Map;

/**
 * 查询条件的 符号（= / != / in / between 等） 枚举
 * @author: 杨联泉
 * @since: 2018/04/16 14:27
 */
public enum SearchOperator {
    Equal("="),
    NotEqual("<>"),
    LessThan("<"),
    LessThanOrEqual("<="),
    GreaterThan(">"),
    GreaterThanOrEqual(">="),
    Like("like"),
    LeftLike("like"),
    RightLike("like"),
    In("in"),
    NotIn("not in"),
    IsNull("is null"),
    NotNull("is not null"),
    Between("between");

    private final String operator;

    private static Map<String, SearchOperator> operators = new HashMap<>();
    static{
        for (SearchOperator operator : SearchOperator.values()) {
            operators.put(operator.getOperator(), operator);
        }
    }

    SearchOperator(String operator){
        this.operator = operator;
    }

    public static SearchOperator getByOperator(String operator){
         return operators.get(operator);
    }
    public String getOperator(){
        return this.operator;
    }
}
